home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1018 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  4.5 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: kanze@gabi-soft.fr (J. Kanze)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: constness of private members and methods
  5. Date: 09 Apr 1996 09:58:25 PDT
  6. Organization: GABI Software, Sarl.
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <KANZE.96Apr9122156@gabi.gabi-soft.fr>
  9. References: <m0u3992-000GcEC@7.kurahaupo.gen.nz> <3161eaa4.8216104@nntp.ix.netcom.com>
  10.     <4jvcrn$ch2@mule1.mindspring.com> <4k3q10$7bd@hermes.synopsys.com>
  11.     <4k7c9s$t5e@mule1.mindspring.com>
  12. NNTP-Posting-Host: isolde.mti.sgi.com
  13. X-Original-Date: 09 Apr 1996 10:21:56 GMT
  14. In-reply-to: abell@mindspring.com's message of 07 Apr 96 08:13:28 GMT
  15. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  16.     iQBVAwUBMWqXMky4NqrwXLNJAQFo1QH9Gi9hbHKlc6vgLJW4PcAb5du1CCZ8avYZ
  17.     yYs2v15BJVVymbem3uczCUT9zBBw3CCjXKeejwU3g3JaqS2BbcXx2A==
  18.     =xly5
  19. Originator: austern@isolde.mti.sgi.com
  20.  
  21. In article <4k7c9s$t5e@mule1.mindspring.com> abell@mindspring.com
  22. (Andrew Bell) writes:
  23.  
  24. |> jbuck@Synopsys.COM (Joe Buck) wrote:
  25. |>  >abell@mindspring.com (Andrew Bell) writes:
  26. |> >>The problem is the compiler needs to know the "purity" of the
  27. |> >>functions a given function calls during its compilation, or it can't
  28. |> >>optimize the code.  You would thus have to compile all the called
  29. |> >>functions first,
  30.  
  31. |> >No, you wouldn't. 
  32.  
  33. |> Tsk, tsk, Joe, you misidentified someone else's statements as Jason's,
  34. |> and then edited out the part I was responding to, thus making it look
  35. |> like I was responding to something I wasn't.  I was responding to
  36. |> Jason's comment that "pure" and "clean" as modifiers weren't necessary
  37. |> with a slightly smarter compiler.  My response was that in that case,
  38. |> all the code would have to be precompiled for purity/cleanliness,
  39. |> before anything could be compiled, a statement I still stand by.
  40.  
  41. Concerning the qualification of `pure': I had considered a pragma for C
  42. to this effect back when I was doing compiler work (late 80's).  In the
  43. end, if I remember right, I decided that it wouldn't work, because most
  44. of the functions you would want to label `pure' in fact aren't.  For
  45. example, most of the mathematical functions (which was the main interest
  46. at the time) aren't pure, because they may modify the global variable
  47. `errno'.
  48.  
  49. I still think that the pragma idea has merit.  There are functions (like
  50. exp or sqrt) that you want to the compiler to treat as pure, even though
  51. they are not pure according to the strict rules.
  52.  
  53. |> >>With the proposed idea, a function that claims to pure and isn't would
  54. |> >>be tagged with a compiler error.  This might be problematic with
  55. |> >>templates, as instantiation for a particular type may lead to non-pure
  56. |> >>functions being called.
  57.  
  58. |> >Replace "pure" with "const".  It's no different.
  59.  
  60. |> In that case, pure would have to be part of the function
  61. |> prototype(specification? Not sure if I'm using the right term here),
  62. |> which would increase its impact on the language specification.  It
  63. |> also means you could conceivably have both pure and impure (*) and
  64. |> clean and unclean versions of the same function, though you could
  65. |> restrict it to not allow this.  
  66.  
  67. To have both versions, you would have to have a criteria in order for
  68. the compiler to select one or the other.  In this case, having both
  69. would imply that any call to the function was, by definition, ambiguous.
  70. So it is implicitly forbidden.  (Note that const/non-const is only valid
  71. for member functions.)
  72.  
  73. |> I suspect the standardization committee might be reluctant to make
  74. |> such a change just for optimization reasons (especially at this
  75. |> point), but maybe there will be a C++ '98 or some such.  (Gotta be,
  76. |> for my wrappers proposal! :-)
  77.  
  78. I am 99.9% certain that such a proposal will not be considered for the
  79. current round of standardization.  It really is too late.  So it won't
  80. make it into C++ '98.  (The year normally refers to the year in which
  81. the standard is formally adapted.  so C++ '98 is about the earliest
  82. possible for this round.)  How about C++ '05?
  83. -- 
  84. James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
  85. GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
  86. Conseils en informatique industrielle --
  87.                             -- Beratung in industrieller Datenverarbeitung
  88. ---
  89. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  90.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  91.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  92.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  93.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  94. ]
  95.